// pages/edu/exam/index/index.js
import { ExamCategory } from '../../model/exam_category.js'
const ExamCategoryModel=new ExamCategory()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    category:{}
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    wx.setNavigationBarTitle({
      title: '考核-艾族大学'
    });
    this._getExamCategory()
  },


  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  },

  // --------------------------------

  _getExamCategory:function(){
    ExamCategoryModel.getTopList((res)=>{
      this.setData({
        category:res
      })
    })
  },


  /**
   * 跳转分类
   * @param {*} event 
   */
  onTapCategory(event){
    let id=event.currentTarget.dataset.id
    let path=event.currentTarget.dataset.path
    if(path){
      wx.navigateTo({
        url: path
      })
    }else{
      wx.navigateTo({
        url: '../category/index?id='+id
      });
    }
    
  }
})